package com.infore.airsupervise.utils;

import com.amap.api.location.AMapLocationClientOption;

/**
 * 定位工具类
 *
 * @features: feature
 * @author: Ding Xinlin
 * @date: 2017/01/18 14:18
 */

public class LocationUtil {

    private static LocationUtil instance = null;

    // 默认间隔时间
    private long defaultInterval = 5 * 60 * 1000;


    private LocationUtil() {
    }

    public static LocationUtil getInstance() {
        if (instance != null) {
            return instance;
        } else {
            instance = new LocationUtil();
            return instance;
        }
    }

    /**
     * 获取单次定位配置
     * @return
     */
    public AMapLocationClientOption getOnceOption() {
        AMapLocationClientOption option = new AMapLocationClientOption();
        option.setLocationMode(AMapLocationClientOption.AMapLocationMode.Hight_Accuracy);
        option.setOnceLocationLatest(true);
        return option;
    }

    /**
     * 获取连续定位配置
     * @param locationInterval 间隔时间(秒)
     * @return
     */
    public AMapLocationClientOption getContinueOption(int locationInterval) {
        AMapLocationClientOption option = new AMapLocationClientOption();
        option.setLocationMode(AMapLocationClientOption.AMapLocationMode.Hight_Accuracy);
        if (locationInterval > 0) {
            option.setInterval(locationInterval * 1000);
        } else {
            option.setInterval(defaultInterval);
        }
        return option;
    }

}
